#include<func.h>
#include"taskQueue.h"
int enQueue(taskQueue_t *pTaskQueue,int Chose,struct sockaddr_in *addr,char *token,char *fileName,char *userName,char *loadtime){
    task_t *pTask = (task_t *)calloc(1,sizeof(task_t));
    pTask->chose = Chose;
    //设置连接ip以及端口号，要与父线程一致
    //测试用
    //printf("enqueue->token: %s\n",token);
    pTask->addr.sin_addr.s_addr = addr->sin_addr.s_addr;
    pTask->addr.sin_family = addr->sin_family;
    pTask->addr.sin_port = addr->sin_port;
    strcpy(pTask->userName,userName);
    strcpy(pTask->loadtime,loadtime);
    //添加文件名
    strcpy(pTask->fileName,fileName);
    //添加token
    strcpy(pTask->token,token);
    //测试用
    //printf("pTask->token: %s\n",pTask->token);
    //将该任务加入到队列中去
    if(pTaskQueue->size == 0){
        pTaskQueue->pFront = pTask;
        pTaskQueue->pRear  = pTask;
    }
    else{
        pTaskQueue->pRear->pNext = pTask;
        pTaskQueue->pRear=pTask;
    }
    ++pTaskQueue->size;
    return 0;
}
int deQueue(taskQueue_t *pTaskQueue){
    task_t *pCur = pTaskQueue->pFront;
    pTaskQueue->pFront = pTaskQueue->pFront->pNext;
    free(pCur);
    --pTaskQueue->size;
}